#!/bin/bash
## kola:
##   # This is a read-only test and can be run with other tests
##   exclusive: false
##   # This test is targeted at AWS
##   platforms: aws
##   # Force this test to not run by default unless named specifically
##   # or `--tag aws-xen-test` is passed to `kola run`. i.e. this test
##   # should only run on Xen instances and the caller should request
##   # the test.
##   requiredTag: aws-xen-test
##   description: Verify that the booted AWS instance is XEN based.

set -xeuo pipefail

# shellcheck disable=SC1091
. "$KOLA_EXT_DATA/commonlib.sh"

token=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
hypervisor=$(curl -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/2022-09-24/meta-data/system || true)
if [ "${hypervisor}" != "xen" ]; then
    fatal "expected xen instance type"
fi

ok xen instance type
